#include "stdafx.h"
#include "IRenderer.h"
#include "IServer.h"
#include "Game.h"

class RendererMock : public IRenderer {
public:
	bool RenderShipCalled;
	RendererMock() : RenderShipCalled(false) { }
	void RenderShip() {
		RenderShipCalled = true;
	}
};

class ServerMock : public IServer {
public:
	bool MoveForwardReceived;
	ServerMock() : MoveForwardReceived(false) { }
	void MoveForward() {
		MoveForwardReceived = true;
	}
};

class TestApp
{
public:
	TestApp() : game(rendererMock, serverMock)
	{
	}
	RendererMock rendererMock;
	ServerMock serverMock;
	Game game;
};


int TestEscape() {
	TestApp app;

	EXPECT( app.game.Alive);

	app.game.EscPressed();
	EXPECT( !app.game.Alive );

	return OK;
}

int Test_a_ship_is_rendered_when_game_starts() {
	TestApp app;

	EXPECT( app.rendererMock.RenderShipCalled );

	return OK;
}

int Pushing_move_forward_sends_message_to_server() {
	TestApp app;
	app.game.MoveForwardPressed();
	EXPECT( app.serverMock.MoveForwardReceived );
	return OK;
}

int TestGame() {
	EXPECT( TestEscape() );

	EXPECT( Test_a_ship_is_rendered_when_game_starts() );

	EXPECT( Pushing_move_forward_sends_message_to_server() );

	return OK;
}
